package org.homonoia.model.core;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Column implements Serializable {

    private static final long serialVersionUID = -835824768083726434L;
    private String cellValue = null;

    public Column(final String value) {
	super();

	this.cellValue = value;
    }

    public final String getValue() {
	return cellValue;
    }

    public int getValueAsInt() {
	return Integer.parseInt(cellValue);
    }

    public float getValueAsFloat() {
	return Float.parseFloat(cellValue);
    }

    public double getValueAsDouble() {
	return Double.parseDouble(cellValue);
    }

    public boolean getValueAsBool() {
	return Boolean.parseBoolean(cellValue);
    }

    public final Date getValueAsDate() throws ParseException {
	return (new SimpleDateFormat().parse(cellValue));
    }

    private void readObject(ObjectInputStream is) throws ClassNotFoundException, IOException {
	is.defaultReadObject();
    }

    private void writeObject(ObjectOutputStream os) throws IOException {
	os.defaultWriteObject();
    }
}
